from fb.open_graph.base import OpenGraphObject

class Song(OpenGraphObject):
  
  def get_open_graph_type(self):
    return 'music.song'
  
  def get_song_duration(self):
    return 0
  
  def get_song_albums(self):
    return ()
  
  def get_song_musicians(self):
    return ()
  
  def get_open_graph_attributes(self):
    attrs = super(Song, self).get_open_graph_attributes()
    attrs.append(('music:duration', self.get_song_duration()))
    
    for album in self.get_song_albums():
      attrs.append(('music:album', album['url']))
      attrs.append(('music:album:disc', album['disc']))
      attrs.append(('music:album:track', album['track']))
      
    for musician in self.get_song_musicians():
      attrs.append(('music:musician', musician))
      
    return attrs
  
  
class Album(OpenGraphObject):
  
  def get_open_graph_type(self):
    return 'music.album'
  
  def get_album_songs(self):
    return ()
    
  def get_album_musicians(self):
    return ()
  
  def get_album_release_date(self):
    return ''
  
  def get_open_graph_attributes(self):
    attrs = super(Album, self).get_open_graph_attributes()
    attrs.append(('music:release_date', self.get_album_release_date()))
    
    for song in self.get_album_songs():
      attrs.append(('music:song', song['url']))
      attrs.append(('music:song:disc', song['disc']))
      attrs.append(('music:song:track', song['track']))
      
    for musician in self.get_album_musicians():
      attrs.append(('music:musician', musician))
      
    return attrs
  

class Playlist(OpenGraphObject):
  
  def get_open_graph_type(self):
    return 'music.playlist'
  
  def get_playlist_creators(self):
    return ()
  
  def get_playlist_songs(self):
    return ()
  
  def get_open_graph_attributes(self):
    attrs = super(Playlist, self).get_open_graph_attributes()
    
    for song in self.get_playlist_songs():
      attrs.append(('music:song', song['url']))
      attrs.append(('music:song:track', song['track']))
    
    for creator in self.get_playlist_creators():
      attrs.append(('music:creator', creator))
      
    return attrs
  
  
class RadioStation(OpenGraphObject):
  
  def get_open_graph_type(self):
    return 'music.radio_station'
  
  def get_radio_station_creators(self):
    return ()
  
  def get_open_graph_attributes(self):
    attrs = super(RadioStation, self).get_open_graph_attributes()
    
    for creator in self.get_radio_station_creators():
      attrs.append(('music:creator', creator))
      
    return attrs
  
    